/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anism.holidays.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author user
 */
@Entity
@Table(name = "clearance", catalog = "holidays", schema = "public")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Clearance.findAll", query = "SELECT c FROM Clearance c"),
    @NamedQuery(name = "Clearance.findByEmployee", query = "SELECT c FROM Clearance c WHERE c.clearancePK.employee = :employee"),
    @NamedQuery(name = "Clearance.findByHolidaysType", query = "SELECT c FROM Clearance c WHERE c.clearancePK.holidaysType = :holidaysType"),
    @NamedQuery(name = "Clearance.findByHours", query = "SELECT c FROM Clearance c WHERE c.hours = :hours")})
public class Clearance implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ClearancePK clearancePK;
    @Column(name = "hours")
    private Integer hours;

    public Clearance() {
    }

    public Clearance(ClearancePK clearancePK) {
        this.clearancePK = clearancePK;
    }

    public Clearance(int employee, int holidaysType) {
        this.clearancePK = new ClearancePK(employee, holidaysType);
    }

    public ClearancePK getClearancePK() {
        return clearancePK;
    }

    public void setClearancePK(ClearancePK clearancePK) {
        this.clearancePK = clearancePK;
    }

    public Integer getHours() {
        return hours;
    }

    public void setHours(Integer hours) {
        this.hours = hours;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (clearancePK != null ? clearancePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Clearance)) {
            return false;
        }
        Clearance other = (Clearance) object;
        if ((this.clearancePK == null && other.clearancePK != null) || (this.clearancePK != null && !this.clearancePK.equals(other.clearancePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.an.ism.holidays.Clearance[ clearancePK=" + clearancePK + " ]";
    }
    
}
